set the visible of card field Help to not visible of card field Help
end mouseUp
-- part 14 (button)
-- low flags: 00
-- high flags: A002
-- rect: left=16 top=319 right=340 bottom=76
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Return
----- HyperTalk script -----
on mouseUp
global returncard
go to returncard
end mouseUp
-- part contents for card part 10
----- text -----
Tower of Hanoi Instructions:
( Click on the title "Tower of Hanoi" above to hide this information. )
This stack demonstrates the use of a recursive algorithm to solve the classic Tower of Hanoi problem. The solution involves movement of a stack of disks from one of three poles to another. There are two very simple rules: only one disk can be moved at a time, and no disk can ever be placed on top of a smaller one. Legend has it that there is an order of Tibetan monks who have been laboring patiently for centuries to move a tower of one hundred disks. The completion of their task will bring the end of the universe. Just how worried should you be? You can use this stack to find out.
Underneath the title button are four buttons that control the operation of this stack. From left to right they are "Make Tower," "Set Tower," "Move Tower," and "See Algorithm."
Click "Make Tower" to create a stack of between 0 and 7 disks. The stack is automatically positioned on the left pole.
To reset the position of the stack of disks, click "Set Tower." A dialog box appears giving you the choice of setting the tower on the left, center, or right poles.
To move the stack of disks using the Tower of Hanoi algorithm, click "Move Tower." Again a dialog box appears allowing you to select the destination pole. The remaining pole, which is neither the source nor the destination, is automatically used as the auxiliary pole. The current depth of recursion and the number of moves are displayed beneath the base of the disk holder. By testing the operation of the algorithm on towers of different heights, you should be able to determine the maximum depth of recursion and the total number of moves in terms of the number of disks in the stack. (See the script of the title button for the answers, and don't cheat!)
To examine the recursive Tower of Hanoi movement handler "moveTower," click "See Algorithm." You may also view the script of the background by typing Command-Option-B to examine the other handlers that support the operation of this stack.
Clicking on the title "Tower of Hanoi" above will hide this information when visible, and will otherwise display the authorship of the stack.